package org.keyyond.ms.scheduler.service.impl;

import org.keyyond.ms.core.util.HttpUtil;
import org.keyyond.ms.scheduler.service.MsEsbJobService;
import org.keyyond.ms.scheduler.util.EncryptUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Service;
@Service
@RefreshScope
public class MsEsbJobServiceFallback implements MsEsbJobService{
	
	@Value("${sendOaUrl}")
	private String sendOaUrl;
	
	@Value("${sendDcpUrl}")
	private String sendDcpUrl;
	
	@Value("${authParam}")
	private String authParam;
	
	private static Logger logger = LoggerFactory.getLogger(MsEsbJobServiceFallback.class);
	
	@Override
	public String autoSyncEc() {
		// TODO Auto-generated method stub
		String encrypt = EncryptUtil.encrypt(authParam);
		String result=null;
		if(encrypt!=null){
			result=HttpUtil.sendPost(sendOaUrl+encrypt, "{}", "UTF-8");
		}else{
			logger.info("加密异常！");
		}
		
		return result;
	}

	@Override
	public String autoSynDcp() {
		// TODO Auto-generated method stub
		String encrypt = EncryptUtil.encrypt(authParam);
		String result=null;
		if(encrypt!=null){
			result = HttpUtil.sendPost(sendDcpUrl+EncryptUtil.encrypt(authParam), "{}", "UTF-8");
		}else{
			logger.info("加密异常！");
		}
		
		return result;
	}

}
